public class J102601 {
    public static String minWindow(String s, String t) {
        String ret = "";
        int len = Integer.MAX_VALUE;
        int[] hashs = new int[58];
        int[] hasht = new int[58];
        int slen = s.length();
        int tlen = t.length();
        int count = 0;

        for (int i = 0; i < tlen; i++) {
            hasht[t.charAt(i) - 'A']++;
        }

        for (int left = 0, right = 0; right < slen; right++) {
            char sr = s.charAt(right);
            hashs[sr - 'A']++;
            if (hashs[sr - 'A'] <= hasht[sr - 'A']) {
                count++;
            }
            int flag = 0;
            while (count == tlen && flag == 0) {
                char sl = s.charAt(left);
                if (hashs[sl - 'A']-- <= hasht[sl - 'A']) {
                    flag = 1;
                    count--;
                }
                left++;
            }
            if (flag == 1 && len > right - left + 1) {
                len = right - left + 1;
                ret = s.substring(left - 1, right + 1);
            }
        }
        return ret;
    }

    public static void main(String[] args) {
        System.out.println(minWindow("ADOBECODEBANC", "ABC"));
    }
}
